{% extends 'base.html' %}

{% block title %}登录 - 电影推荐系统{% endblock %}

{% block content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h3 class="mb-0">登录</h3>
            </div>
            <div class="card-body">
                {% if messages %}
                <div class="messages mb-3">
                    {% for message in messages %}
                    <div class="alert alert-{{ message.tags }}">
                        {{ message }}
                    </div>
                    {% endfor %}
                </div>
                {% endif %}
                
                <form method="post">
                    {% csrf_token %}
                    <div class="mb-3">
                        <label for="id_username" class="form-label">用户名</label>
                        <input type="text" name="username" class="form-control" id="id_username" required>
                        {% if form.username.errors %}
                        <div class="text-danger small mt-1">
                            {% for error in form.username.errors %}
                            {{ error }}
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    <div class="mb-3">
                        <label for="id_password" class="form-label">密码</label>
                        <input type="password" name="password" class="form-control" id="id_password" required>
                        {% if form.password.errors %}
                        <div class="text-danger small mt-1">
                            {% for error in form.password.errors %}
                            {{ error }}
                            {% endfor %}
                        </div>
                        {% endif %}
                    </div>
                    {% if form.non_field_errors %}
                    <div class="alert alert-danger">
                        {% for error in form.non_field_errors %}
                        {{ error }}
                        {% endfor %}
                    </div>
                    {% endif %}
                    <button type="submit" class="btn btn-primary">登录</button>
                </form>
                
                <div class="mt-3">
                    <p>还没有账号？<a href="{% url 'register' %}">注册</a></p>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 